package me.itxuye.moment.base;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
import me.itxuye.moment.utils.TestUrls;

/**
 * Author  : itxuye(itxuye@gmail.com)|(http://itxuye.com)
 * Date    : 2015-11-30
 * Time    : 23:14
 * FIXME
 */
public abstract class BaseFragment extends Fragment implements TestUrls {

  public Activity mActivity;
  public View view;

  /*
    提供布局ID
 */
  abstract protected int provideContentViewId();

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mActivity = getActivity();
  }

  @Nullable @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {

    view = inflater.inflate(provideContentViewId(), container, false);
    ButterKnife.bind(this, view);
    initViews();
    initData();
    return view;
  }

  @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
  }

  //初始化view
  protected abstract void initViews();

  //初始化data
  protected abstract void initData();
}
